import { defineStore } from 'pinia'

// useStore 可以是 useUser、useCart 之类的任何东西
// 第一个参数是应用程序中 store 的唯一 id

interface State {
    userCount: number
}
export const useStore = defineStore('main', {
    state(): State  {
        return {
            userCount: 0,
        }
    },
    getters: {
        doubleCount: (state) => state.userCount * 2,
    },
    actions: {
        init() {
          this.userCount = Number(localStorage.getItem('userCount'))
        },
        increment() {
            this.userCount++
        },
    },
})